#ifndef __BOARD_H
#define __BOARD_H

#include "led.h"
#include <stdbool.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "ringbuffer8.h"
#include "Shell.h"
#include "event_groups.h"
#include <stdbool.h>

// 宏开关
#define     DEBUG       1

/* DHT1 DQ总线 参数控制*/
#define   DHT11_PORT    GPIOA
#define   DHT11_PIN     GPIO_Pin_6

// 任务句柄外部可调用
extern TaskHandle_t voice_task_handle;
extern TaskHandle_t shell_task_handle;
extern TaskHandle_t dht11_task_handle;
extern TaskHandle_t warning_task_handle;
extern TaskHandle_t oled_task_handle;
extern TaskHandle_t key_task_handle;
extern TaskHandle_t adc_task_handle;
extern TaskHandle_t wfi_task_handle;


// 信号量句柄外部可调用
extern QueueHandle_t dht_init_bin;
extern SemaphoreHandle_t voice_ctr_rx_binary;
extern SemaphoreHandle_t wfi_wait_user_binary;

// 互斥信号量句柄外部可调用
extern SemaphoreHandle_t wfi_user_mutex_bin; // 互斥信号量句柄

// 队列外部可调用
extern QueueHandle_t extern_to_oled_queue;
extern QueueHandle_t extern_to_oled_data;

// led驱动定义
struct led_selc;
typedef struct led_selc led_initTypeDef;
typedef struct led_selc* led_t;
//void board_lowlever_init(led_t led_init_struct);
void led_init(void);
void led_set_onoff(led_t led,bool bit);
void led_toggle(led_t led);
extern led_t led1;
extern led_t led2;
extern led_t led3;
extern led_t led4;
extern led_t led5;
typedef struct key_selc* key_t;

/* key结构体部分 */
struct key_selc
{
    GPIO_TypeDef*    gpio_port;
    uint32_t         gpio_pin;
    uint8_t          value;
};
typedef struct key_selc* key_t;
/* key函数声明 */
void key_init(void);
bool key_press(key_t user_key_x);
/* 按键结构体声明外部可调用 */
extern key_t key1;
extern key_t key2;
extern key_t key3;
extern key_t key4;
extern key_t key5;

/* 初始化函数声明外部可调用 */
extern void board_lowlever_init(void);
extern void warning_buzzer_init(void);

/* 任务函数声明 */
void shell_task(void* param);
void dht11_task(void* param);
void voice_task(void* param);
void oled_task(void* param);
void key_task(void* param);
void adc_task(void* param);
void wfi_task(void* param);
void warning_task(void* param);

/* letter shell 缓冲区大小 */
#define     RBBUFFER_SIZE           512

/* shell 缓存数据区 */
extern ringbuffer8_t serial_rb;
extern uint8_t serial_rx_buffer[];

// letter shell配合ringbuffer缓冲数据
#define     SHELL_BUFFER_SIZE       1024
extern Shell shell;
extern char shell_buffer[SHELL_BUFFER_SIZE];

/* 语音模块函数声明 */
void voice_module_send_command(uint8_t command);

#endif
